GDK/GTK on Windows: Fix build
authorChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 21 Aug 2013 13:54:09 +0000 (21:54 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 26 Aug 2013 02:29:23 +0000 (10:29 +0800)
Due to the work on gdk_cursor_new_from_surface (commit b2113b73),
get_cursor_for_pixbuf() in GdkDisplayClass was converted to
get_cursor_for_surface(), which means the GDK Win32 backend needs to be
updated for the code to build and run on Windows, plus some function
prototypes and declarations/calls need to be updated as well.

https://bugzilla.gnome.org/show_bug.cgi?id=705980

gdk/win32/gdkcursor-win32.c
gdk/win32/gdkdevice-wintab.c
gdk/win32/gdkdisplay-win32.c
gdk/win32/gdkprivate-win32.h
gdk/win32/gdkwin32misc.h
gtk/gtkicontheme.c

index 1ce7cb1ec4a5c41fd709c7467b7cfcb6436baa62..a0cd1e5f47eb37b5c2bfd2272b11224b7c9f1eb7 100644 (file)
@@ -250,7 +250,9 @@ _gdk_win32_display_get_cursor_for_name (GdkDisplay  *display,
 }
 
 GdkPixbuf *
-gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon, gint *x_hot, gint *y_hot)
+gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
+                                      gdouble *x_hot,
+                                      gdouble *y_hot)
 {
   GdkPixbuf *pixbuf = NULL;
   ICONINFO ii;
@@ -430,7 +432,7 @@ _gdk_win32_cursor_get_surface (GdkCursor *cursor,
                               gdouble *y_hot)
 {
   GdkPixbuf *pixbuf;
-  cairo_surface_t *surface
+  cairo_surface_t *surface;
 
   g_return_val_if_fail (cursor != NULL, NULL);
 
@@ -446,19 +448,33 @@ _gdk_win32_cursor_get_surface (GdkCursor *cursor,
 }
 
 GdkCursor *
-_gdk_win32_display_get_cursor_for_pixbuf (GdkDisplay *display, 
-                                         GdkPixbuf  *pixbuf,
-                                         gint        x,
-                                         gint        y)
+_gdk_win32_display_get_cursor_for_surface (GdkDisplay *display,
+                                         cairo_surface_t  *surface,
+                                         gdouble          x,
+                                         gdouble          y)
 {
   HCURSOR hcursor;
+  GdkPixbuf *pixbuf;
+  gint width, height;
 
   g_return_val_if_fail (display == _gdk_display, NULL);
+  g_return_val_if_fail (surface != NULL, NULL);
+
+  width = cairo_image_surface_get_width (surface);
+  height = cairo_image_surface_get_height (surface);
+  pixbuf = gdk_pixbuf_get_from_surface (surface,
+                                        0,
+                                        0,
+                                        width,
+                                        height);
+
   g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
   g_return_val_if_fail (0 <= x && x < gdk_pixbuf_get_width (pixbuf), NULL);
   g_return_val_if_fail (0 <= y && y < gdk_pixbuf_get_height (pixbuf), NULL);
 
   hcursor = _gdk_win32_pixbuf_to_hcursor (pixbuf, x, y);
+
+  g_object_unref (pixbuf);
   if (!hcursor)
     return NULL;
   return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
index 369821cb088c8e20e3ef19377fc035975bd8aaf0..199e7aa90c77a350c966d84c7b1f23ac8ec7e5c0 100644 (file)
@@ -40,8 +40,8 @@ static void gdk_device_wintab_set_window_cursor (GdkDevice *device,
                                                  GdkCursor *cursor);
 static void gdk_device_wintab_warp (GdkDevice *device,
                                     GdkScreen *screen,
-                                    gint       x,
-                                    gint       y);
+                                    gdouble   x,
+                                    gdouble   y);
 static void gdk_device_wintab_query_state (GdkDevice        *device,
                                            GdkWindow        *window,
                                            GdkWindow       **root_window,
@@ -170,8 +170,8 @@ gdk_device_wintab_set_window_cursor (GdkDevice *device,
 static void
 gdk_device_wintab_warp (GdkDevice *device,
                         GdkScreen *screen,
-                        gint       x,
-                        gint       y)
+                        gdouble   x,
+                        gdouble   y)
 {
 }
 
index d03e272da382220c5c792056e20a8a3ee14fc25a..3f83a8397185e82fe94ba44a776abacc235c00bc 100644 (file)
@@ -658,7 +658,7 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
   //? display_class->get_app_launch_context = _gdk_win32_display_get_app_launch_context;
   display_class->get_cursor_for_type = _gdk_win32_display_get_cursor_for_type;
   display_class->get_cursor_for_name = _gdk_win32_display_get_cursor_for_name;
-  display_class->get_cursor_for_pixbuf = _gdk_win32_display_get_cursor_for_pixbuf;
+  display_class->get_cursor_for_surface = _gdk_win32_display_get_cursor_for_surface;
   display_class->get_default_cursor_size = _gdk_win32_display_get_default_cursor_size;
   display_class->get_maximal_cursor_size = _gdk_win32_display_get_maximal_cursor_size;
   display_class->supports_cursor_alpha = _gdk_win32_display_supports_cursor_alpha;
index 3c2fed9149098663d19a4d39234b4ccad4bdc9a8..acc3fcac05cfa2874e8a2f646be688959d4047b5 100644 (file)
@@ -373,10 +373,10 @@ GdkCursor *_gdk_win32_display_get_cursor_for_type (GdkDisplay   *display,
                                                   GdkCursorType cursor_type);
 GdkCursor *_gdk_win32_display_get_cursor_for_name (GdkDisplay  *display,
                                                   const gchar *name);
-GdkCursor *_gdk_win32_display_get_cursor_for_pixbuf (GdkDisplay *display, 
-                                                    GdkPixbuf  *pixbuf,
-                                                    gint        x,
-                                                    gint        y);
+GdkCursor *_gdk_win32_display_get_cursor_for_surface (GdkDisplay *display,
+                                                    cairo_surface_t  *surface,
+                                                    gdouble          x,
+                                                    gdouble          y);
 void     _gdk_win32_display_get_default_cursor_size (GdkDisplay  *display,
                                                     guint       *width,
                                                     guint       *height);
index 36b52153b9404708fa23d82bfa286b62dd9779dd..dadb4e23e11e57ab2ecf520d0a3365bcc9faf64f 100644 (file)
@@ -98,7 +98,9 @@ GdkWindow *   gdk_win32_window_lookup_for_display (GdkDisplay *display,
 
 /* For internal GTK use only */
 GDK_AVAILABLE_IN_ALL
-GdkPixbuf    *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon);
+GdkPixbuf    *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
+                                                    gdouble *x_hot,
+                                                    gdouble *y_hot);
 GDK_AVAILABLE_IN_ALL
 HICON         gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
 GDK_AVAILABLE_IN_ALL
index b1e02a89df045bae8165bd652f65906ed7b86341..2ce68fdbe1be8d24bd5af0b52b47aac1ee4b3b9a 100644 (file)
@@ -1690,7 +1690,7 @@ choose_icon (GtkIconTheme       *icon_theme,
       if (hIcon)
        {
          icon_info = icon_info_new ();
-         icon_info->cache_pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (hIcon);
+         icon_info->cache_pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (hIcon, NULL, NULL);
          DestroyIcon (hIcon);
           icon_info->dir_type = ICON_THEME_DIR_UNTHEMED;
           icon_info->dir_size = size;